package com.expand.learn.controller;

import com.expand.learn.annotation.AppResponseBody;
import com.expand.learn.model.Human;
import com.expand.learn.model.Person;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zhanghaidong
 * @version v1.0
 * @description
 * @date 2020/2/27
 */
@RequestMapping("/spring/expand2")
@Controller
public class Test2Controller {

    @AppResponseBody
    @RequestMapping(value = "/getPerson", method = RequestMethod.POST)
    public Person parsePerson(Human human) {
        final Person person = human.getPerson();
        System.out.println(" Test2Controller ----" + person.toString());
        return person;
    }

    /**
     * http请求的 Accept 与 produces 对应
     * @param name
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/myMedia", method = RequestMethod.GET, produces = "application/x-custom")
    public Person myMedia(String name) {
        return new Person(name, 22);
    }
}
